<script>
	import Vue from 'vue';
	import store from 'store';
	// #ifdef H5
	// import '@/common/vconsole.min.js';
	// #endif
	let currentUrl = '';
	export default {
		onLaunch: function() {
			if (this.$isIOSWechat()) {
				console.log('1121')
				this.initUrlTracking();
			}
			
			// #ifdef H5
			// setTimeout(()=>{
			// new VConsole()
			// },500)
			// #endif
			console.log('App Launch')
			uni.getSystemInfo({
				success: function(e) {
					// console.log(e)
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.ScreenWidth = e.screenWidth;
					Vue.prototype.ScreenHeight = e.screenHeight;
					Vue.prototype.windowWidth = e.windowWidth;
					Vue.prototype.windowHeight = e.windowHeight;
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};

					// #endif

					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif		

					// #ifdef MP-ALIPAY
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			$isIOSWechat() {
				const ua = navigator.userAgent.toLowerCase();
				return /iphone|ipad|ipod/.test(ua) && /micromessenger/.test(ua);
			},
			initUrlTracking() {
				// 初始URL
				const base = window.location.origin + (process.env.VUE_APP_BASE_URL || '/sale/');
				currentUrl = base + this.$route.fullPath.replace(/^\//, '');

				// 监听路由变化
				this.$router.afterEach((to) => {
					currentUrl = base + to.fullPath.replace(/^\//, '');
				});
				let url = this.$isIOSWechat() ? currentUrl : window.location.href.split('#')[0];
				store.state.currentUrl = url;
			},
			$getCurrentUrl() {
				return this.$isIOSWechat() ? currentUrl : window.location.href.split('#')[0];
			}
		}
	}
</script>

<style lang="less">
	/*每个页面公共css */
	page {
		font-size: 28rpx;
		color: #383D45;
	}

	view {
		box-sizing: border-box;
	}

	.container {
		position: relative;
		z-index: 1;
	}

	.contents {
		padding: 30rpx;
	}

	/*
		font-size   f-[12-36]
	 */
	.font(@n, @i: 12) when (@i <=@n) {
		.f-@{i} {
			font-size: @i * 2rpx;

		}

		.font(@n, (@i+1))
	}

	.font(36);

	/**
	 * font-weight: 600;  f-w-600
	 * font-weight: 700;  f-w-700
	 */
	.f-w-600 {
		font-weight: 600;
	}

	.f-w-700 {
		font-weight: 700;
	}

	.fontBold {
		font-weight: bold;
	}

	.fontNormal {
		font-weight: normal;
	}

	/* 
		padding-left 	 p-l-[1-30]
		padding-right    p-r-[1-30]
		padding-top      p-t-[1-30]
		padding-bottom   p-b-[1-30]
	 */
	.p-l(@n, @i: 1) when (@i <=@n) {
		.p-l-@{i} {
			padding-left: @i * 2rpx;
		}

		.p-l(@n, (@i+1))
	}

	.p-l(40);

	.p-r(@n, @i: 1) when (@i <=@n) {
		.p-r-@{i} {
			padding-right: @i * 2rpx;
		}

		.p-r(@n, (@i+1))
	}

	.p-r(40);

	.p-t(@n, @i: 1) when (@i <=@n) {
		.p-t-@{i} {
			padding-top: @i * 2rpx;
		}

		.p-t(@n, (@i+1))
	}

	.p-t(30);

	.p-b(@n, @i: 1) when (@i <=@n) {
		.p-b-@{i} {
			padding-bottom: @i * 2rpx;
		}

		.p-b(@n, (@i+1))
	}

	.p-b(30);

	/* 
		margin-left    m-l-[1-30]
		margin-right   m-r-[1-30]
		margin-top     m-t-[1-30]
		margin-bottom  m-b-[1-30]
	*/
	.m-l(@n, @i: 1) when (@i <=@n) {
		.m-l-@{i} {
			margin-left: @i * 2rpx !important;
		}

		.m-l(@n, (@i+1))
	}

	.m-l(40);

	.m-r(@n, @i: 1) when (@i <=@n) {
		.m-r-@{i} {
			margin-right: @i * 2rpx !important;
		}

		.m-r(@n, (@i+1))
	}

	.m-r(40);

	.m-t(@n, @i: 1) when (@i <=@n) {
		.m-t-@{i} {
			margin-top: @i * 2rpx;
		}

		.m-t(@n, (@i+1))
	}

	.m-t(30);

	.m-b(@n, @i: 1) when (@i <=@n) {
		.m-b-@{i} {
			margin-bottom: @i * 2rpx;
		}

		.m-b(@n, (@i+1))
	}

	.m-b(30);

	/*
		border-radius    b-r-[5%-50%]
	*/
	.b-r(@n, @i: 5) when (@i <=@n) {
		.b-r-@{i} {
			border-radius: @i * 2rpx;
		}

		.b-r(@n, (@i+1))
	}

	.b-r(50);

	/*
		z-index   z-[1-100]
	 */
	.z-i(@n, @i: 1) when (@i <=@n) {
		.z-i-@{i} {
			z-index: @i;
		}

		.z-i(@n, (@i+1))
	}

	.z-i(100);

	/**
	 * 	flex
	 */
	.scale-1px-bottom {
		position: relative;
		border: none;
	}

	.scale-1px-bottom::after {
		content: '';
		position: absolute;
		bottom: 0;
		right: 0;
		background: #dddddd;
		height: 1px;
		width: 100%;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
		-webkit-transform-origin: 0 0;
		transform-origin: 0 0;
	}

	.width100 {
		width: 100%;
	}

	.width50 {
		width: 50%;
	}

	.height100 {
		height: 100%;
	}

	.position-rel {
		position: relative;
	}

	.absolute {
		position: absolute;
	}

	.relative {
		position: relative;
	}

	.dis-inline {
		display: inline-block;
	}

	.flex {
		display: flex;
	}

	.flex-1 {
		flex: 1;
	}

	.flex-none {
		flex: none;
	}

	.flex-direction {
		flex-direction: column;
	}

	.flex-wrap {
		flex-wrap: wrap;
	}

	.align-center {
		align-items: center;
	}

	.align-start {
		align-items: flex-start !important;
	}

	.align-end {
		align-items: flex-end !important;
	}

	.justify-center {
		justify-content: center;
	}

	.justify-space-between {
		justify-content: space-between;
	}

	.justify-space-around {
		justify-content: space-around;
	}

	.justify-start {
		justify-content: flex-start;
	}

	.justify-end {
		justify-content: flex-end !important;
	}

	.align-self-end {
		align-self: flex-end;
	}

	.overHidden {
		overflow: hidden;
	}

	/**
	 * text-overflow-1  单行溢出隐藏
	 * text-overflow-n  多行溢出隐藏
	 */
	.text-overflow-1 {
		// white-space: nowrap;
		// overflow: hidden;
		// text-overflow: ellipsis;

		display: -webkit-box;
		line-clamp: 1;
		-webkit-line-clamp: 1;
		box-orient: vertical;
		-webkit-box-orient: vertical;
		word-break: break-all;
		overflow: hidden;
	}

	.text-overflow(@n, @i: 2) when (@i <=@n) {
		.text-overflow-@{i} {
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: @i;
			-webkit-box-orient: vertical;
		}

		.text-overflow(@n, (@i+1))
	}

	.text-overflow(5);

	.text-center {
		text-align: center;
	}

	.text-right {
		text-align: right;
	}

	.text-left {
		text-align: left;
	}

	.text-pre-wrap {
		white-space: pre-wrap;
	}

	/**
	 * 	color	primary   主题红色
	 * 			orange    辅助橙色
	 * 	  		blue      蓝色按钮
	 * 			success   绿色
	 * 			red       红色
	 * 			brown     会员深棕色
	 * 			gray      字体灰色
	 * 			yellow    淡黄
	 */
	.bg-col {
		background-color: #f6f6f6; // 灰色背景底色
	}

	.bg-white {
		background-color: #fff;
	}

	.bg-grays {
		background-color: #999;
	}

	.bg-blue {
		background-color: #529EFF;
	}

	.bg-green {
		background-color: #76b44f;
	}

	.bg-orange {
		background-color: #f58035;
	}

	.bg-red {
		background-color: #ff3c3c;
	}

	.bg-yellow {
		background-color: #e7b500;
	}

	.primary {
		color: #FF7D61;
	}

	.orange {
		color: #FF3F13;
	}
	.yellow {
		color: #FFCB00;
	}
	.blue {
		color: #529EFF;
	}

	.blue-s {
		color: #62C8FF;
	}

	.success {
		color: #0aa713;
	}

	.red {
		color: #de1923;
	}

	.red-2 {
		color: #f13c5f;
	}

	.brown {
		color: #9f330d;
	}

	.purple {
		color: #6935d2;
	}

	.grey {
		color: #ABACB4;
	}

	.white {
		color: #FFFFFF !important;
	}

	.black-9 {
		color: #999999 !important;
	}

	.black-6 {
		color: #666666 !important;
	}

	.black-3 {
		color: #333333 !important;
	}

	.black-4 {
		color: #444444 !important;
	}

	.black {
		color: #000000 !important;
	}

	.black-b {
		color: #bbbbbb !important;
	}

	.black-1 {
		color: #181818;
	}

	.black-57 {
		color: #575a60;
	}

	/**
	 * btn-[small,large,normal]
	 */
	uni-button {
		margin: 0;
	}

	uni-button[plain],
	.button-hover[plain] {
		display: flex;
		justify-content: center;
		align-items: center;
		line-height: 1;
		color: #FFFFFF;
		border: none;
	}

	.btn-small-1 {
		width: 130rpx;
		height: 60rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		border: none !important;
		color: #FFFFFF !important;
	}

	.btn-small-2 {
		width: 150rpx;
		height: 60rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		border: none !important;
		color: #FFFFFF !important;
	}

	.btn-small-3 {
		width: 180rpx;
		height: 66rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		border: none !important;
		color: #FFFFFF !important;
	}

	.btn-small-4 {
		width: 230rpx;
		height: 74rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		border: none !important;
		color: #FFFFFF !important;
	}

	.btn-large {
		margin: 0 40rpx;
		height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
		color: #FFFFFF !important;
		border: none !important;
	}

	.btn-normal {
		width: 100%;
		height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 30rpx;
		color: #FFFFFF !important;
		border: none !important;
	}

	.nodata {
		text-align: center;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		color: #aaaaaa;
		font-size: 30upx;
		z-index: 10;
	}

	.textarea-auto-mini {
		min-height: 38upx;
	}

	.textarea-auto-x {
		min-height: 100upx;
	}

	.textarea-auto-xl {
		min-height: 150upx;
	}

	.border-box {
		box-sizing: border-box;
	}

	.bottom-shadow {
		width: 100%;
		height: 1px;
		box-shadow: 0upx 0upx 30upx 0upx rgba(55, 60, 67);
		position: fixed;
		/* #ifdef H5 */
		bottom: 50px;
		/* #endif */
		/* #ifndef H5 */
		bottom: 0;
		/* #endif */
		left: 0;
		z-index: 10;
	}
</style>